package com.phantomjs;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;

/**
 * Hello world!
 *
 */
public class Test {
	public static void main(String[] args) {
		
		DesiredCapabilities caps = new DesiredCapabilities();
        caps.setJavascriptEnabled(true);  
        caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
		
		WebDriver driver = new PhantomJSDriver(caps);
		driver.get("http://www.autohome.com.cn/car/");
		
		
		for(int i=0;i<5;i++){
			System.out.println("=================="+i);
			
			JavascriptExecutor js = (JavascriptExecutor)driver;
			js.executeScript("var q=document.documentElement.scrollTop=100000");
		}
		String pageSource = driver.getPageSource();
		System.out.println(pageSource.length());
		driver.close();
	}
}
